package com.sise.studentInfoSystem.mapper;

import com.sise.studentInfoSystem.domain.TAcademic;
import com.sise.studentInfoSystem.domain.TStudent;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author zzp
 * @Desc
 * @Date 2020/7/6
 */
public interface StudentMapper {

    @Select("select * from tb_student where stu_id=#{stuID} and password=#{stuPwd}")
    TStudent findStuByIdAndPwd(String stuID,String stuPwd);

    @Update("update tb_student set head_img=#{imgPath} where stu_id=#{stuID}")
    void updateImgByID(String imgPath,String stuID);

    @Select("select password from tb_student where stu_id = #{stuId}")
    String findPwdById(String stuId);

    @Update("update tb_student set password=#{newPwd} where stu_id=#{stuID}")
    int updatePwdById(String newPwd,String stuID);

    @Update("update tb_student set signature=#{newSignature} where stu_id=#{stuID}")
    int updateSignatureById(String newSignature, String stuID);

    @Update("update tb_student set hobby=#{newHobby} where stu_id=#{stuID}")
    int updateHobbyById(String newHobby, String stuID);

    @Insert("insert into tb_academic(stu_id,basic_points,failed_num,subtotal,status) values(#{stuId},#{basicPoints},#{failedNum},#{subtotal},#{status})")
    int uploadAcademic(TAcademic academic);

    @Select("select * from tb_academic where stu_id = #{stuId}")
    TAcademic findAcademicById(String stuId);

    @Delete("delete from tb_academic where stu_id = #{stuId}")
    int delAcademicById(String stuId);

    @Select("select * from tb_student where stu_id=#{adminId} and password=#{adminPwd} and role=1")
    TStudent findStuByIdAndPwdAndRole(String adminId, String adminPwd);

    @Select("select * from tb_student where classes=#{classes} limit #{begin},#{size}")
    List<TStudent> findStuByClassess(String classes,Integer begin,Integer size);

    @Select("select count(*) from tb_student where classes=#{classes}")
    Integer findStuCountByClasses(String classes);

    @Select("select * from tb_student where classes=#{classes} and stu_name like '%${condition}%' limit #{begin},#{size}")
    List<TStudent> findStuByClassessAndCondition(String classes, String condition, Integer begin, Integer size);

    @Select("select * from tb_student where classes=#{classes}")
    List<TStudent> findAllStuByClassess(String classes);

    @Select("select count(*) from tb_student where classes=#{classes}")
    int findCountByClass(String classes);

    @Select("select count(*) from tb_academic  where status = #{status} and  stu_id in (select stu_id from tb_student where classes=#{classes})")
    int findAcademicCountByStuIdAndStatus(String classes, String status);

    @Select("select count(*) from tb_profrssional_skills  where status = #{status} and  stu_id in (select stu_id from tb_student where classes=#{classes})")
    int findProfrssionalSkillCountByStuIdAndStatus(String classes, String status);
}
